package com.xwltz.entity;

import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@Data
@Document
public class Student {

    @Id
    @NotNull(message = "不能为空")
    private String id;

    @Field
    @NotEmpty(message = "姓名不能为空")
    @Length(min = 2, message = "最小字符不能小于2位")
    private String name;

    @Field
    @Min(value = 16, message = "年龄必须大于16")
    private int age;
}
